document.getElementById('uploadForm').addEventListener('submit', async (e) => {
    e.preventDefault();
    const file = document.getElementById('fileInput').files[0];
    const formData = new FormData();
    formData.append('file', file);

    try {
        // 调用后端API接口
        const response = await fetch('/upload', {
            method: 'POST',
            body: formData
        });
        if (response.ok) {
            document.getElementById('status').textContent = '上传成功！';
        } else {
            const error = await response.json();
            document.getElementById('status').textContent = '上传失败：' + error.error;
        }
    } catch (error) {
        document.getElementById('status').textContent = '上传失败：' + error.message;
    }
});